<?php
namespace app\common\model;

use think\Model;

class Archives extends Model
{
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

	//关联组
	public function category()
    {
        return $this->belongsTo(Category::class);
    }


    public function files()
    {
        return $this->belongsToMany(Files::class, ArchivesFiles::class);
    }


	public function searchCategoryIdAttr($query, $value, $data)
    {
        $query->where('category_id','in', $value);
    }

	public function searchTitleAttr($query, $value, $data)
    {
        $query->where('title','like', '%'.$value.'%');
    }


    public function getStatusTextAttr($value,$data)
    {
        $status = [0=>'禁用',1=>'正常'];
        return $status[$data['status']];
    }


}